﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SHARED;

namespace MSSQL_Connection
{
    public partial class SubFormMSSQLConnection : Form
    {
        public string val;
        public SubFormMSSQLConnection()
        {
            InitializeComponent();
        }

        private void textBoxDataSource_TextChanged(object sender, EventArgs e)
        {
            
        }

        private void btnTestConnection_Click(object sender, EventArgs e)
        {
        //    if (textBoxServerName.Text, textBoxDBName.Text, textBoxUserId.Text, textBoxPassword.Text)
        }

        private bool validateUserInput()
        {
            bool isValid = true;
            if (textBoxMSSQLServerName.Text.Trim() == string.Empty || textBoxMSSQLDBName.Text.Trim() == string.Empty
                || textBoxMSSQLUserId.Text.Trim() == string.Empty || textBoxMSSQLPassword.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Please fill all required fields.", "Error: Invalid entry");
                isValid = false;
            }
            //if (textBoxMSSQLDBName.Text.Trim() == string.Empty)
            //{
            //    MessageBox.Show("Database name is required.", "Error: Invalid entry");
            //    isValid = false;
            //}
            //if (textBoxMSSQLUserId.Text.Trim() == string.Empty)
            //{
            //    MessageBox.Show("User ID is required.", "Error: Invalid entry");
            //    isValid = false;
            //}
            //if (textBoxMSSQLPassword.Text.Trim() == string.Empty)
            //{
            //    MessageBox.Show("Password is required.", "Error: Invalid entry");
            //    isValid = false;
            //}
            return isValid;
        }

                private void textBoxServerName_TextChanged(object sender, EventArgs e)
        {

        }

        private void SubFormConnection_Load(object sender, EventArgs e)
        {
            
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnTestConnection_Click_1(object sender, EventArgs e)
        {
            //ms
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!validateUserInput())
            {
                return;
            }
        }

        private void textBoxMSSQLServerName_Leave(object sender, EventArgs e)
        {
            //if (textBoxMSSQLServerName.Text == "")
            //{
            //    MessageBox.Show("Server name is required.");
            //    //textBoxMSSQLServerName.Focus();
            //}

        }

    }
}
